#!/bin/sh

sed -e "s,local_vip '1',local_vip 'cvip',g" \
    -e "/local_vip '0'/d" \
    -e "/music_source 'default'/d" \
	-i "/etc/config/unblockneteasemusic"

uci -q batch <<-EOF >"/dev/null"
	delete ucitrack.@unblockneteasemusic[-1]
	commit ucitrack
EOF

if [ -e "$(command -v fw4)" ]; then
	uci -q batch <<-EOF >"/dev/null"
		delete firewall.unblockneteasemusic
		set firewall.unblockneteasemusic=include
		set firewall.unblockneteasemusic.type=nftables
		set firewall.unblockneteasemusic.path=/var/run/unblockneteasemusic/fw4.nft
		set firewall.unblockneteasemusic.position=table-post
		commit firewall
	EOF
else
	uci -q batch <<-EOF >"/dev/null"
		delete firewall.unblockneteasemusic
		set firewall.unblockneteasemusic=include
		set firewall.unblockneteasemusic.type=script
		set firewall.unblockneteasemusic.path=/var/run/unblockneteasemusic/fw3.include
		set firewall.unblockneteasemusic.reload=1
		commit firewall
	EOF
fi

rm -f /tmp/luci-indexcache
exit 0
